<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><s:property value="#session.goods.name"/></title>
<link href="Public/plugins/hplus/css/bootstrap.min.css?v=3.3.6"
	rel="stylesheet">
<link href="Public/plugins/hplus/css/font-awesome.min.css?v=4.4.0"
	rel="stylesheet">
<link href="Public/plugins/hplus/css/animate.css" rel="stylesheet">
<link href="Public/plugins/hplus/css/style.css?v=4.1.0" rel="stylesheet">
<link href="Public/public/pace-theme-flash.css" rel="stylesheet">
<link href="Public/home/css/public/common.css" rel="stylesheet">
<link rel="stylesheet" type="text/css"
	href="Public/Lala/css/sale/zzsc.css">
<link rel="stylesheet" type="text/css"
	href="Public/home/css/sale/goodsdis.css">
<link type="text/css" href="Public/Fonts/iconfont.css" rel="stylesheet" />

<style type="text/css">
@font-face {
	font-family: "iconfont";
	src: url('iconfont.eot'); /* IE9*/
	src: url('iconfont.eot#iefix') format('embedded-opentype'),
		/* IE6-IE8 */
          url('iconfont.woff') format('woff'), /* chrome, firefox */
          url('iconfont.ttf') format('truetype'),
		/* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
          url('iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */
}

.iconfont {
	font-family: "iconfont" !important;
	font-size: 16px;
	font-style: normal;
	-webkit-font-smoothing: antialiased;
	-webkit-text-stroke-width: 0.2px;
	-moz-osx-font-smoothing: grayscale;
}
</style>
<script src="js/jquery.js"></script>
<script type="text/javascript">
	function getQueryVariable(variable) {
		var query = window.location.search.substring(1);
		var vars = query.split("&");
		for (var i = 0; i < vars.length; i++) {
			var pair = vars[i].split("=");
			if (pair[0] == variable) {
				return pair[1];
			}
		}
		return (false);
	}
	$(document)
			.ready(function() {
						var _url = "${pageContext.request.contextPath }/buyAjax?id="
								+ getQueryVariable("id")
						$
								.getJSON(
										_url,
										function(data) {
											var str = "";
											$
													.each(
															data['review'],
															function(i, n) {
																str += "<li class='list-item clearfix'>"
																		+ "<div class='head'>"
																		+ "<img src="+n.users.images+">"
																		+ "</div>"
																		+ "<div class='text' id='content'>"
																		+ "<div class='user clearfix'>"
																		+ " <div class='username'>"
																		+ n.users.name
																		+ "<span class='reply'>"
																		+ "回复"
																		+ "</span>"
																		+ n.goods.users.name
																		+ "</div>"
																		+ "<div class='info'>"
																		+ "<span class='reply-time'>"
																		+ "</span>"
																		+ "<span class='reply'>"
																		+ "回复"
																		+ "</span>"
																		+ "</div></div>"
																		+ " <p class='detail' style='padding-left: 0;'>"
																		+ n.review
																		+ "</p></div></li>";
															});
											document
													.getElementById("reply-list").innerHTML = str;
										});
					})
	function reclk() {

		var value = document.getElementById('commoncontent').value;
		$.getJSON("${pageContext.request.contextPath }/Review", {
			review : value,
			uid : "<s:property value='#session.user.id'/>",
			gid : '<s:property value="#session.goods.id" />'
		}, function(data) {
			var str = "";
			$.each(data['review'], function(i, n) {
				str += "<li class='list-item clearfix'>" + "<div class='head'>"
						+ "<img src="+n.users.images+">" + "</div>"
						+ "<div class='text' id='content'>"
						+ "<div class='user clearfix'>"
						+ " <div class='username'>" + n.users.name
						+ "<span class='reply'>" + "回复" + "</span>"
						+ n.goods.users.name + "</div>" + "<div class='info'>"
						+ "<span class='reply-time'>" + "</span>"
						+ "<span class='reply'>" + "回复" + "</span>"
						+ "</div></div>"
						+ " <p class='detail' style='padding-left: 0;'>"
						+ n.review + "</p></div></li>";
			});
			console.log(str);

			document.getElementById("reply-list").innerHTML = str;
		});
	}

	function cli(x) {
		if (x.innerHTML == '收起更多的精彩评论') {
			x.innerHTML = '展开更多的精彩评论';
			//5
			var _url ="${pageContext.request.contextPath }/ReviewFenYe?FenYe=five&id="+getQueryVariable("id") 
			$.getJSON(_url,
				function(data) {
				var str = "";
				$.each(data['review'], function(i, n) {
					str += "<li class='list-item clearfix'>" + "<div class='head'>"
							+ "<img src="+n.users.images+">" + "</div>"
							+ "<div class='text' id='content'>"
							+ "<div class='user clearfix'>"
							+ " <div class='username'>" + n.users.name
							+ "<span class='reply'>" + "回复" + "</span>"
							+ n.goods.users.name + "</div>" + "<div class='info'>"
							+ "<span class='reply-time'>" + "</span>"
							+ "<span class='reply'>" + "回复" + "</span>"
							+ "</div></div>"
							+ " <p class='detail' style='padding-left: 0;'>"
							+ n.review + "</p></div></li>";
				});
				console.log(str);

				document.getElementById("reply-list").innerHTML = str;
			});
		} else {
			x.innerHTML = '收起更多的精彩评论';
			//all
			var _url ="${pageContext.request.contextPath }/ReviewFenYe?FenYe=all&id="+getQueryVariable("id") 
			$.getJSON(_url,
				function(data) {
				var str = "";
				$.each(data['review'], function(i, n) {
					str += "<li class='list-item clearfix'>" + "<div class='head'>"
							+ "<img src="+n.users.images+">" + "</div>"
							+ "<div class='text' id='content'>"
							+ "<div class='user clearfix'>"
							+ " <div class='username'>" + n.users.name
							+ "<span class='reply'>" + "回复" + "</span>"
							+ n.goods.users.name + "</div>" + "<div class='info'>"
							+ "<span class='reply-time'>" + "</span>"
							+ "<span class='reply'>" + "回复" + "</span>"
							+ "</div></div>"
							+ " <p class='detail' style='padding-left: 0;'>"
							+ n.review + "</p></div></li>";
				});
				console.log(str);

				document.getElementById("reply-list").innerHTML = str;
			});
		}
	}
</script>
<script>
function saleFavor(){
	alert("收藏成功");
	window.location.href="${pageContext.request.contextPath }/collect?gid="+<s:property value='#session.goods.id'/>+"&uid="+<s:property value='#session.user.id'/>+"&id="+<s:property value='#session.goods.id'/>+"&type=collect";
}
function Login(){
	alert("请先登录");
}
function Cancle(){
	alert("删除");
	window.location.href="${pageContext.request.contextPath }/collect?gid="+<s:property value='#session.goods.id'/>+"&id="+<s:property value='#session.goods.id'/>+"&type=cancle";
}

</script>
</head>

<body>

	<s:include value="nav.jsp"></s:include>

	<div class="item-box">
		<s:include value="menu.jsp"></s:include>
	</div>
	<div class="sidebar">
		<div class="btn block">
			<div class="ershou">
				<a href="Fabu">发布二手</a>
			</div>
			<div class="qiugou">
				<a href="/release/buy">发布求购</a>
			</div>
		</div>
	</div>

	<div class="main"
		style="padding-left: 180px; padding-right: 160px; padding-top: 85px; width: 100%; border-style: solid solid none; border-width: 4px 0px 0; border-color: #e7eaec;">
		<div class="detail clearfix">
			<div class="picture">
				<div class="con-FangDa" id="fangdajing">
					<div class="con-fangDaIMg">
						<img src="<s:property value="#session.goods.images" />">
					</div>
					<ul class="con-FangDa-ImgList">
						<!-- 图片显示列表 -->
						<li class="active"><img
							src="<s:property value="#session.goods.images" />"></li>
					</ul>
				</div>
			</div>
			<div class="info">
				<ul>
					<li class="title"><span> <s:property value="#session.goods.name" /></span></li>
					<li class="price"><span class="howmuch"><s:property
								value="#session.goods.price" />元</span></li>
					<li class="user same"><span class="name"> <span
							class="icon iconfont">&#xe732;</span> &nbsp;&nbsp;<span><s:property
									value="#session.goods.users.name" /></span>
					</span></li>


					<li class="contact2 same"><span class="qq"> <span
							class="icon iconfont">&#xe65c;</span> &nbsp;&nbsp;&nbsp;
					</span> <s:if test="#session.user==null">
							<a target="_blank" href="Login.jsp" style="text-decoration: none">
								<span class="needlogin">点击登录后可查看</span>
							</a>
						</s:if> <s:else>
							<span class="text"><s:property value="#session.goods.qq" /></span>
						</s:else></li>



					<li class="contact2 same"><span class="tel"> <span
							class="icon iconfont">&#xe693;</span> &nbsp;&nbsp;&nbsp;
					</span> <s:if test="#session.user==null">
							<a target="_blank" href="Login.jsp" style="text-decoration: none">
								<span class="needlogin">点击登录后可查看</span>
							</a>
						</s:if> <s:else>
							<span class="text"> <s:property
									value="#session.goods.phone" /></span>
						</s:else></li>




					<li class="contact2 same"><span class=""><span
							class="iconfont">&#xe68a;</span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span
						class="text"><s:property value="#session.goods.school.name" /></span></li>
					<li class="address same"><span class=""><span
							class="iconfont">&#xe624;</span>&nbsp;&nbsp;&nbsp;</span><span
						class="text"><s:property value="#session.goods.address" /></span></li>
					<li class="time same"><span class=""><span
							class="icon iconfont">&#xe670;</span> &nbsp;&nbsp;&nbsp;</span> <span
						class="text"> <s:property value="#session.goods.date" />
					</span></li>
					<li>
						<div style="margin-top: 5px; height: 32px; line-height: 32px;"
							class="jiathis_style_32x32">
							<s:if test="#session.user==null">
							<button type="button" class="btn btn-success"
								onclick="Login()">收藏</button>
							 </s:if>
							
						
							 <s:else>
							 
							<s:if test="#request.collect==null||#request.collect.state==0">
							 <button type="button" class="btn btn-success"
								onclick="saleFavor()">收藏</button>
							 </s:if>
							  <s:else>
							 <button type="button" class="btn btn-success"
								onclick="Cancle()">已收藏</button>
							 </s:else>
							 </s:else>
						 	 
							
							<button type="button" class="btn btn-warning"
								onclick="saleReport(2438)">举报</button>
						</div>
					</li>
				</ul>
			</div>
		</div>
		<div class="ershou-desc">
			<div class="desc clearfix">
				<a target="_blank"> <img
					src='<s:property value="#session.goods.users.images" />'
					style="border-radius: 100%; float: left; height: 80px; margin-right: 20px; vertical-align: middle; width: 80px;" />
				</a> <span id="user_cmt"> <s:property
						value="#session.goods.introduce" /><br>(联系我的时候，请说明是在青稞校园看见的噢！)
				</span>
			</div>
		</div>
		<s:if test="#session.user==null">
			<div class="commonbox">
				<div class="commontip">评论</div>
				<div class="box">
					<ul class="reply-list" id="reply-list">

					</ul>
					<div class="more-appraise">
						<div class="btn" onclick="cli(this)">展开更多的精彩评论</div>
					</div>
					<p id="reply-to-tips">
						<s:property value="#session.user.name" />
						回复
						<s:property value="#session.goods.users.name" />
						：
					</p>
					<div class="common">

						<img src='images/moren.png'>
						<textarea id="commoncontent" disabled="disabled">您要登录之后才能评论哟</textarea>
						<button id="commonbtn" class="commonbtn" class="reply">评论</button>
					</div>
					</div>
					</div>
		</s:if>
		<s:else>
			<div class="commonbox">
				<div class="commontip">评论</div>
				<div class="box">
					<ul class="reply-list" id="reply-list">

					</ul>
					<div class="more-appraise">
						<div class="btn" onclick="cli(this)">展开更多的精彩评论</div>
					</div>
					<p id="reply-to-tips">
						<s:property value="#session.user.name" />
						回复
						<s:property value="#session.goods.users.name" />
						：
					</p>
					<div class="common">
						<img src='<s:property value="#session.user.images"/>'>
						<textarea id="commoncontent"></textarea>
						<button id="commonbtn" class="commonbtn" class="reply"
							onclick="reclk()">评论</button>
					</div>
				</div>
			</div>
		</s:else>

	</div>
	<s:include value="footer.jsp"></s:include>

</body>

</html>